<p>
    <?php //echo $message ?>
</p>
<form method="post" action="<?php echo url_for('@mod_rules_edit_matrix?id=' . $rules->getId()) ?>">

    Nazwa <input type="text" name="rules[name]" value="<?php echo $rules->getName() ?>" /><br />
    Wolne punkty <input type="text" name="rules[freepts]" value="<?php echo $rules->getFreepts() ?>" /><br />
    <?php if ($rules->getType() == gameRules::$RT_MATRIX): ?>
        Gracz A <input type = "text" name = "rules[player_a]" value = "<?php echo $matrix->getPlayerLabel(0) ?>" /><br />
        Gracz B <input type = "text" name = "rules[player_b]" value = "<?php echo $matrix->getPlayerLabel(1) ?>" /><br />
        Sposób naliczania punktów:
        <select name="rules[win_type]">
            <option value="0" <?php echo $matrix->getWinPoints() == gameRules::$GW_Less ? 'selected="selected"' : '' ?> >mniejsza</option>
            <option value="1" <?php echo $matrix->getWinPoints() == gameRules::$GW_Greater ? 'selected="selected"' : '' ?> >większa</option>
        </select> liczba wygrywa<br />
        Warunek końca meczu:
        do <input name="rules[end_value]" type="text" size="3" value="<?php echo $matrix->getMatchEndValue() ?>" /> 
        <select name="rules[end_type]">
            <option value="0" <?php echo $matrix->getMatchEndType() == gameRules::$EM_GAME ? 'selected="selected"' : '' ?> >gier</option>
            <option value="1" <?php echo $matrix->getMatchEndType() == gameRules::$EM_POINTS_DIF ? 'selected="selected"' : '' ?> >punktów przewagi</option>
            <option value="2" <?php echo $matrix->getMatchEndType() == gameRules::$EM_POINTS ? 'selected="selected"' : '' ?> >punktów</option>
            <option value="3" <?php echo $matrix->getMatchEndType() == gameRules::$EM_WINS ? 'selected="selected"' : '' ?> >zwycięstw</option>
        </select>
        <br />
        <table class="rules_matrix_table">
            <tr>
                <td></td>
                <?php $i = 0;
                foreach ($matrix->getRows() as $row):
                    ?>
                    <td colspan="2" class="matrix_actions2 ingame_action"><img class="option_img" src="/images/iAction.png"><input type="text" name="rules[rows_<?php echo $i++ ?>]" value="<?php echo $row ?>" /></td>
                <?php endforeach ?>
            </tr>
            <?php $size = $matrix->getSize();
            $j = 0
            ?>
            <?php $k = 0;
            foreach ($matrix->getCols() as $col):
                ?>
                <tr class="matrix_row">
                    <td class="matrix_actions1 matrix_row ingame_action"><img class="option_img" src="/images/iAction.png"><input type="text" name="rules[cols_<?php echo $j ?>]" value="<?php echo $col ?>" /></td>
        <?php for ($i = 0; $i < $size[0]; $i++): ?>
                                <?php $cell = $matrix->getCell($i, $j) ?>
                        <td class="matrix_cell1 matrix_row"><span class="cell_points1"><input type="text" name="rules[cell_<?php echo $k ?>_0]" value="<?php echo $cell[0] ?>" /></span></td>
                        <td class="matrix_cell2 matrix_row"><span class="cell_points2"><input type="text" name="rules[cell_<?php echo $k++ ?>_1]" value="<?php echo $cell[1] ?>" /></span></td>
                <?php endfor ?>
                <?php $j++ ?>
                </tr>
        <?php endforeach ?>
        </table>
    <?php else: ?>
        Gracz A <input type = "text" name = "rules[player_a]" value = "<?php echo $tree->getPlayerLabel(0) ?>" /><br />
        Gracz B <input type = "text" name = "rules[player_b]" value = "<?php echo $tree->getPlayerLabel(1) ?>" /><br />
        Sposób naliczania punktów:
    <select name="rules[win]">
        <option value="0" <?php echo $tree->getWinPoints() == gameRules::$GW_Less ? 'selected="selected"' : '' ?> >mniejsza</option>
        <option value="1" <?php echo $tree->getWinPoints() == gameRules::$GW_Greater ? 'selected="selected"' : '' ?> >większa</option>
    </select> liczba wygrywa<br />
Warunek końca meczu:
        do <input name="rules[end_value]" type="text" size="3" value="<?php echo $tree->getMatchEndValue() ?>" /> 
        <select name="rules[end]">
            <option value="0" <?php echo $tree->getMatchEndType() == gameRules::$EM_GAME ? 'selected="selected"' : '' ?> >gier</option>
            <option value="1" <?php echo $tree->getMatchEndType() == gameRules::$EM_POINTS_DIF ? 'selected="selected"' : '' ?> >punktów przewagi</option>
            <option value="2" <?php echo $tree->getMatchEndType() == gameRules::$EM_POINTS ? 'selected="selected"' : '' ?> >punktów</option>
            <option value="3" <?php echo $tree->getMatchEndType() == gameRules::$EM_WINS ? 'selected="selected"' : '' ?> >zwycięstw</option>
        </select>
        <br />
            
            
            <?php endif ?>    
    
    <input type="submit" value="Zapisz" /><br />
    
    
    <?php if($rules->getType()==gameRules::$RT_TREE){ echo '<div style="margin: 50px auto;"><a href="'.url_for('@mod_rules_edit_tree_rep'.'?id='.$rules->getId()).'">Edytuj drzewo</a></div>';} ?>
</form>